package com.ruoyi.project.system.interact.controller;

import java.util.List;

import com.ruoyi.project.system.interact.domain.Exhibition;
import com.ruoyi.project.system.interact.service.IExhibitionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.StringUtils;

/**
 * 云游展厅Controller
 * 
 * @author ruoyi
 * @date 2023-07-15
 */
@Controller
@RequestMapping("/hui/interact/exhibition")
public class ExhibitionController extends BaseController
{
    private String prefix = "system/interact/exhibition";

    @Autowired
    private IExhibitionService exhibitionService;

    @RequiresPermissions("hui:interact:exhibition:view")
    @GetMapping()
    public String exhibition()
    {
        return prefix + "/exhibition";
    }

    /**
     * 查询云游展厅列表
     */
    @RequiresPermissions("hui:interact:exhibition:query")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Exhibition exhibition)
    {
        startPage();
        List<Exhibition> list = exhibitionService.selectExhibitionList(exhibition);
        return getDataTable(list);
    }

    /**
     * 导出云游展厅列表
     */
    @RequiresPermissions("hui:interact:exhibition:export")
    @Log(title = "云游展厅", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Exhibition exhibition)
    {
        List<Exhibition> list = exhibitionService.selectExhibitionList(exhibition);
        ExcelUtil<Exhibition> util = new ExcelUtil<Exhibition>(Exhibition.class);
        return util.exportExcel(list, "云游展厅数据");
    }

    /**
     * 新增云游展厅
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存云游展厅
     */
    @RequiresPermissions("hui:interact:exhibition:add")
    @Log(title = "云游展厅", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Exhibition exhibition)
    {
        exhibition.setCreateBy(getLoginName());
        return toAjax(exhibitionService.insertExhibition(exhibition));
    }

    /**
     * 修改云游展厅
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Exhibition exhibition = exhibitionService.selectExhibitionById(id);
        mmap.put("exhibition", exhibition);
        return prefix + "/edit";
    }

    /**
     * 修改保存云游展厅
     */
    @RequiresPermissions("hui:interact:exhibition:edit")
    @Log(title = "云游展厅", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Exhibition exhibition)
    {
        exhibition.setUpdateBy(getLoginName());
        return toAjax(exhibitionService.updateExhibition(exhibition));
    }

    /**
     * 查看云游展厅详情
     */
    @GetMapping("/view/{id}")
    public String view(@PathVariable("id") Long id, ModelMap mmap)
    {
        Exhibition exhibition = exhibitionService.selectExhibitionById(id);
        mmap.put("exhibition", exhibition);
        return prefix + "/view";
    }

    /**
     * 删除云游展厅
     */
    @RequiresPermissions("hui:interact:exhibition:remove")
    @Log(title = "云游展厅", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(exhibitionService.deleteExhibitionByIds(ids));
    }
}